package cn.zx.springtask.springboottasktest.task;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 定时任务类
 * @author zhaoxiang
 * @version 1.0
 * @Date 2019/9/4 16:01
 */
@Component("myTask")
public class MyTask {

    @Scheduled(initialDelay = 1000,fixedDelay = 1000)
    public void firstTask(){
        System.out.println("这是第一个定时任务firstTask："+new Date());
    }

    @Scheduled(cron = "*/5 * * * * ?")
    public void secondTask() {
        System.out.println("这是第二个定时任务secondTask："+new Date());
    }
}
